/**
 * 通用类型定义
 */

// 用户角色
export type UserRole = 'admin' | 'teacher' | 'student'

// 用户信息
export interface User {
  id: number
  username: string
  email: string
  first_name: string
  last_name: string
  phone?: string
  avatar?: string
  role: UserRole
  is_active: boolean
  date_joined: string
  last_login?: string
}

// 登录表单
export interface LoginForm {
  username: string
  password: string
}

// 注册表单
export interface RegisterForm {
  username: string
  email: string
  first_name: string
  last_name: string
  phone?: string
  password: string
  confirm_password: string
}

// API响应
export interface ApiResponse<T = any> {
  code?: number
  message?: string
  data?: T
  results?: T[]
  count?: number
  next?: string
  previous?: string
}

// 分页参数
export interface PaginationParams {
  page?: number
  page_size?: number
  search?: string
  ordering?: string
}

// 学校信息
export interface School {
  id: number
  name: string
  code: string
  address?: string
  phone?: string
  website?: string
  description?: string
  is_active: boolean
  created_at: string
  updated_at: string
}

// 专业信息
export interface Major {
  id: number
  school: number
  school_info?: School
  name: string
  code: string
  degree_type: 'bachelor' | 'master' | 'doctor' | 'college'
  duration: number
  description?: string
  is_active: boolean
  created_at: string
  updated_at: string
}

// 年级信息
export interface Grade {
  id: number
  major: number
  major_info?: Major
  year: number
  name: string
  total_students: number
  is_active: boolean
  created_at: string
  updated_at: string
}

// 班级信息
export interface Class {
  id: number
  grade: number
  grade_info?: Grade
  name: string
  class_number: number
  total_students: number
  head_teacher?: number
  head_teacher_info?: User
  is_active: boolean
  created_at: string
  updated_at: string
}

// 用户账号信息（简化版，用于学生列表）
export interface UserInfo {
  id: number
  username: string
  is_active: boolean
  date_joined: string
  last_login?: string
}

// 学生信息
export interface Student {
  id: number
  user?: UserInfo  // 用户账号信息
  student_id: string
  name: string
  gender: 'M' | 'F'
  phone?: string
  email?: string
  grade: number
  grade_info?: Grade
  status: 'active' | 'graduated' | 'suspended' | 'dropped'
  employment_status: 'unemployed' | 'employed' | 'self_employed' | 'further_study'
  resume_status: 'not_started' | 'in_progress' | 'submitted' | 'approved' | 'rejected'
  advisor?: number
  advisor_info?: User
  created_at: string
  updated_at: string
}

// 简历信息
export interface Resume {
  id: number
  student: number
  template?: number
  title: string
  status: 'draft' | 'in_progress' | 'submitted' | 'under_review' | 'approved' | 'rejected'
  current_step: number
  completion_rate: number
  reviewer?: number
  review_date?: string
  review_comments?: string
  generated_file?: string
  created_at: string
  updated_at: string
}

// 面试信息
export interface Interview {
  id: number
  student: number
  interviewer: number
  interview_type: 'practice' | 'mock' | 'assessment'
  title: string
  description?: string
  scheduled_time: string
  actual_start_time?: string
  actual_end_time?: string
  status: 'scheduled' | 'in_progress' | 'completed' | 'cancelled'
  location?: string
  overall_score?: number
  feedback?: string
  suggestions?: string
  created_at: string
  updated_at: string
}

// 公司信息
export interface Company {
  id: number
  name: string
  code?: string
  company_type: 'startup' | 'sme' | 'large' | 'multinational' | 'government' | 'ngo'
  company_size: '1-10' | '11-50' | '51-200' | '201-500' | '501-1000' | '1000+'
  industry: string
  website?: string
  description?: string
  address: string
  contact_person?: string
  contact_phone?: string
  contact_email?: string
  logo?: string
  founded_year?: number
  employee_count?: number
  created_at: string
  updated_at: string
}

// 岗位信息
export interface Job {
  id: number
  company: number
  company_info?: Company
  title: string
  job_type: 'full_time' | 'part_time' | 'internship' | 'contract' | 'remote'
  work_mode: 'online' | 'offline' | 'hybrid'
  department?: string
  salary_min?: number
  salary_max?: number
  salary_negotiable: boolean
  work_location: string
  remote_allowed: boolean
  description: string
  requirements: string
  responsibilities: string
  benefits?: string
  required_skills?: string
  preferred_skills?: string
  education_requirement?: string
  experience_requirement?: string
  positions_available: number
  application_deadline?: string
  contact_email: string
  contact_phone?: string
  is_long_term: boolean
  valid_from?: string
  valid_until?: string
  status: 'draft' | 'published' | 'closed' | 'expired'
  is_featured: boolean
  published_by: number
  published_by_name?: string
  published_at?: string
  salary_range?: string
  created_at: string
  updated_at: string
}

// 岗位申请信息
export interface JobApplication {
  id: number
  job: number
  job_info?: Job
  student: number
  student_info?: {
    id: number
    student_id: string
    name: string
    email: string
    phone: string
    grade?: string
  }
  cover_letter?: string
  resume_file?: string
  status: 'pending' | 'approved' | 'rejected'
  reviewed_by?: number
  reviewed_by_name?: string
  review_comments?: string
  reviewed_at?: string
  created_at: string
  updated_at: string
}

// 通知信息
export interface Notification {
  id: number
  recipient: number
  sender?: number
  notification_type: 'system' | 'resume' | 'interview' | 'job'
  title: string
  content: string
  priority: 'low' | 'normal' | 'high' | 'urgent'
  related_object_type?: string
  related_object_id?: number
  is_read: boolean
  read_at?: string
  is_sent: boolean
  sent_at?: string
  created_at: string
}

// 菜单项
export interface MenuItem {
  id: string
  title: string
  icon?: string
  path?: string
  children?: MenuItem[]
  roles?: UserRole[]
  hidden?: boolean
}

// 统计数据
export interface Statistics {
  [key: string]: number | string | Statistics
}
